//package zhao.tx.eecs.AbsActivity;
//
//import android.os.Bundle;
//import android.support.v7.app.ActionBar;
//import android.util.Log;
//import android.view.Gravity;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.LinearLayout;
//import android.widget.LinearLayout.LayoutParams;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//
//import com.andware.yuanjiex.R;
//
//
///**
// * Created by ishishuji on 14-6-27.
// */
//public abstract class SubBaseActivity extends BaseActivity {
//
//
//    private RelativeLayout customBarView = null;
//
//    private TextView titleView = null;
//
//    @Override
//    protected void onCreate ( Bundle savedInstanceState ) {
//        super.onCreate ( savedInstanceState );
//        if ( actionBar != null ) {
//            actionBar.setDisplayOptions ( ActionBar.DISPLAY_SHOW_CUSTOM );
//
//            resumeActionBar ( R.layout.custom_actionbar );
//
//        }
//
//    }
//
//    public void resumeActionBar ( int layout ) {
//        customBarView = ( RelativeLayout ) LayoutInflater.from ( this ).inflate( layout,
//                        null);
//
//        ActionBar.LayoutParams params = new ActionBar.LayoutParams(
//                ActionBar.LayoutParams.MATCH_PARENT,
//                ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER );
//
//        actionBar.setCustomView(customBarView, params);
//
//        titleView = ( TextView ) customBarView.findViewById ( R.id.actionTitle );
//
//    }
//
//    public void setActionBarBackgroundColor ( int color ) {
//        if ( customBarView != null ) {
//            customBarView.setBackgroundColor ( color );
//            updateCustomBarView ();
//        }
//    }
//
//    public void setActionBarBackgroundResource ( int resource ) {
//        if ( customBarView != null ) {
//            customBarView.setBackgroundResource ( resource );
//            updateCustomBarView ();
//        }
//    }
//
//    private void updateCustomBarView () {
//        if ( customBarView != null ) {
//            customBarView.postInvalidate ();
//        }
//    }
//
//    public void setCustomTitle ( String title ) {
//        if ( titleView != null ) {
//            titleView.setText ( title );
//        }
//    }
//
//    public void addIconToActionBarCenter ( View... centerViews ) {
//        if ( customBarView != null ) {
//
//            LinearLayout linearLayout = new LinearLayout ( this );
//            linearLayout.setOrientation ( LinearLayout.HORIZONTAL );
//            linearLayout.setGravity ( Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL );
//            LayoutParams params = new LayoutParams ( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT );
//            params.topMargin = 10;
//            params.bottomMargin = 10;
//
//            linearLayout.setLayoutParams ( params );
//            for ( View center : centerViews ) {
//                Log.i ("addCenter","addToCenter");
//
//                linearLayout.addView ( center );
//            }
//            addViewToCenter ( linearLayout );
//        }
//
//    }
//
//    private void addViewToCenter ( View centerView ) {
//        if ( customBarView != null ) {
//            if ( titleView != null ) {
//                titleView.setVisibility ( View.GONE );
//            }
//            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT  );
//
//            params.addRule ( RelativeLayout.CENTER_IN_PARENT );
//
//            addSubView ( centerView,params );
//        }
//    }
//
//    public void addIconToActionBarRight ( View rightView  ) {
//        if ( customBarView != null ) {
//            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT  );
//            setParamsStatus ( params , false );
//            addSubView ( rightView,params );
//        }
//    }
//
//    private void setParamsStatus ( RelativeLayout.LayoutParams params, boolean isLeft ) {
//        if ( isLeft ) {
//            params.addRule ( RelativeLayout.ALIGN_PARENT_LEFT );
//            params.leftMargin = 30;
//        } else {
//            params.addRule ( RelativeLayout.ALIGN_PARENT_RIGHT );
//            params.rightMargin = 30;
//        }
//        params.addRule ( RelativeLayout.CENTER_VERTICAL );
//    }
//
//    public void addIconToActionBarLeft ( View leftView  ) {
//        if ( customBarView != null ) {
//            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT  );
//            setParamsStatus ( params , true );
//            addSubView ( leftView,params );
//        }
//    }
//
//    private void addSubView ( View subView , RelativeLayout.LayoutParams params ) {
//
//        customBarView.addView ( subView, params );
//        customBarView.postInvalidate ();
//    }
//
//    public void addIconToActionBarLeft ( View leftView , int width_dp , int height_dp ) {
//        if ( customBarView != null ) {
//            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( width_dp,height_dp );
//            setParamsStatus ( params,true );
//            addSubView ( leftView,params );
//        }
//    }
//
//
//    public void addIconToActionBarRight ( View rightView , int width_dp , int height_dp ) {
//        if ( customBarView != null ) {
//            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams ( width_dp,height_dp );
//            setParamsStatus ( params,false );
//
//            addSubView ( rightView,params );
//        }
//    }
//
//    public View getCustomBarView () {
//        return customBarView;
//    }
//
//    public void setCustomBarView ( RelativeLayout customBarView ) {
//        this.customBarView = customBarView;
//    }
//}
